<?php
require_once('includes/config.php');
require_once('includes/functions/func.global.php');
require_once('includes/classes/class.template_engine.php');
require_once('includes/lang/lang_'.$config['lang'].'.php');

// Start the session
session_start();

// Connect to the database
db_connect($config);

// Check if the user has a remember cookie set
checkremember($config);

// Get site categories
$cats = get_cats($config);

if(!isset($_GET['id']))
{
	echo 'No id specified';
	exit;
}

$query = "SELECT html_title,html_content,template FROM `".$config['db']['pre']."html` WHERE html_id='".addslashes($_GET['id'])."' LIMIT 1";
$query_result = @mysql_query ($query) OR error(mysql_error(), __LINE__, __FILE__, 0, '', '');
while ($info = @mysql_fetch_array($query_result))
{
	$html = stripslashes($info['html_content']);
	$title = stripslashes($info['html_title']);
	$tpl = $info['template'];
}

if(!isset($title))
{
	exit;
}

if($tpl)
{
	$page = new HtmlTemplate ("templates/" . $config['tpl_name'] . "/html_content_no.html");
}
else
{
	$page = new HtmlTemplate ("templates/" . $config['tpl_name'] . "/html_content.html");
}
$page->SetLoop ('CATS', $cats);
$page->SetParameter ('SITE_TITLE',$config['site_title']);
$page->SetParameter ('TITLE', $title);
$page->SetParameter ('HTML', $html);
$page->SetParameter ('OVERALL_HEADER', create_header($config,$lang,$cats));
$page->SetParameter ('OVERALL_FOOTER', create_footer($config,$lang));
if(isset($_SESSION['duser']['id']))
{
	$page->SetParameter ('LOGGEDIN', 1);
}
else
{
	$page->SetParameter ('LOGGEDIN', 0);
}
$page->CreatePageEcho($lang,$config);
?>